﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using skhukb.Models;
using skhukb.DB;
using System.Data.Linq;

namespace skhukb.Controllers
{
    [Authorize]
    public class SubjectPickerController : Controller
    {

        [skhukb.Util.AjaxOnly]
        public ActionResult Search(string pattern, string callback = null) // Referenced By: Subject/_Move.cshtml
        {
            using (var db = new DBDataContext()) {
                var 주제목록 = db.주제.Where(p => p.제거 == false);
                if (pattern != null && pattern.Trim().Length > 0)
                    주제목록 = 주제목록.Where(p => p.제목.Contains(pattern));
                var 모델 = new SubjectPickerSearchModel {
                    콜백함수 = callback,
                    주제목록 = 주제목록.Select(p => new 주제Model(p)).ToList()
                };
                return PartialView(모델);
            }
        }

    }
}
